package jmai.scanner;

import java.util.*;

/**
 * @author - SDavis 4/2009
 * This class represents an AST Node in the AST Tree structure.
 */
public class ASTNode {

	/** enum for the type of AST Node */
    public enum ASTNodeType {
        ROOTNODE, PAIRNODE, REGEXNODE, ACTIONNODE, PARAMETERNODE 
    }

    /** stores type of AST Node */
    private ASTNodeType nodeType;

    /** stores the AST Node data as a string */
    private String nodeData;

    /** stores the child AST Nodes of the current AST Node */
    private LinkedList<ASTNode> nodeChildren;
   
    /**
     * @param inNodeType - type of node being created
     * This is the constructor for the class.
     */
    public ASTNode(ASTNodeType inNodeType) {

        nodeType = inNodeType;
        nodeData = "";
        nodeChildren = new LinkedList<ASTNode>();

    }

    /**
     * @param inNodeType - type of node
     * This module sets the node type.
     */   
    public void SetNodeType(ASTNodeType inNodeType) {

        nodeType = inNodeType;

    }

    /**
     * @return type of node
     * This module gets the node type.
     */     
    public ASTNodeType GetNodeType() {

        return nodeType;

    } 

    /**
     * @return linked list of children of current node
     * This module gets the list of child nodes.
     */     
    public LinkedList<ASTNode> GetNodeChildren() {

        return nodeChildren;

    }  

    /**
     * @param inNodeData - data of node
     * This module sets the node data.
     */     
    public void SetNodeData(String inNodeData) {

        nodeData = inNodeData;

    }

    /**
     * @return String for data of node
     * This module gets the node data.
     */     
    public String GetNodeData() {

        return nodeData;

    }  

    /**
     * @param inASTNode - AST Node to be added as child of current AST Node
     * This module adds a child AST Node to the current AST Node.
     */     
    public void AddChildNode(ASTNode inASTNode) {

        nodeChildren.add(inASTNode);

    }

    /**
     * @param inListIndex - index of child AST Node to be returned
     * @return AST Node child of current AST Node
     * This module gets a child AST Node of the current AST Node.
     */     
    public ASTNode GetChildNode(int inListIndex) {

        return nodeChildren.get(inListIndex);

    }

    /**
     * This module removes the last child node of the current node.
     */     
    public void RemoveLastChildNode() {
    
    	nodeChildren.removeLast();
    	
    }
    
}
